package dou_di_zhu;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;

import zuoye_3_10.Player;

public class DouDiZhu {
	public static void main(String[] args) {
        //准备牌
		ArrayList<Integer> poker=new ArrayList<Integer>();
		//定义两个数组
		String[] colors={"♥","♣","♦","♠"}; 
		String[] numbers={"2","A","K","Q","J","10","9","8","7","6","5","4","3"};
		
		//组装52张牌
		HashMap<Integer,String> map = new HashMap<>();
		map.put(0, "大王");
		map.put(1, "小王");
		int Key = 1;
		poker.add(0);
		poker.add(1);
		for(String number:numbers){
			for(String color:colors){
				Key++;
				poker.add(Key);
				map.put(Key,color+number);
			}
		}
		
		
		
		//洗牌
		Collections.shuffle(poker);
		
		Player playe1=new Player("老王");
		Player playe2=new Player("老李");
		Player playe3=new Player("老刘");
		//摸牌
		for(int i=0;i<poker.size();i++){
			//每一张牌
			Integer p = poker.get(i);
			if(i<=51){
				if(i%3==0){
					playe1.getList().add(p);
				}else if(i%3==1){
					playe2.getList().add(p);
				}else{
					playe3.getList().add(p);
				}
			}
		}
		Collections.sort(playe1.getList());
		Collections.sort(playe2.getList());
		Collections.sort(playe3.getList());
		//看牌
		System.out.println(playe1.getName());				
		for(int i : playe1.getList()){
			System.out.printf(map.get(i)+",");
		}
		System.out.println(" ");
        System.out.println(playe2.getName());
		for(int i : playe2.getList()){
			System.out.printf(map.get(i)+",");
		}
		System.out.println(" ");
		System.out.println(playe3.getName());
		for(int i : playe3.getList()){
			System.out.printf(map.get(i)+",");
		}
		
		
}
}
